package jpb.module.service.profession;

import jpb.module.dao.profession.ProfessionDao;
import jpb.module.daomain.profession.Profession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by haol on 2017/4/5.
 */
@Service
public class ProfessionService {
        @Autowired
        private ProfessionDao professionDao;

        public void add(Profession profession) {
                professionDao.add(profession);
        }

        public Profession get(String oid, String name) {
                return professionDao.get(oid, name);
        }


        public void update(Profession profession) {
                professionDao.update(profession);
        }


        public void delete(Integer pid) {
                professionDao.delete(pid);
        }

        public List<Profession> get(String oid) {
                return professionDao.getByOid(oid);
        }

        public Profession get(Integer id) {
                return professionDao.get(id);
        }

        public Profession getByOidAndName(String name, String oid) {
                return professionDao.get(name, oid);
        }

        public boolean checkIsExist(String oid,Integer pid){
                Profession profession = professionDao.get(pid);
                return professionDao.get(oid,profession.getName()) != null;
        }
        public Profession getByOidAndMemberNum(String oid,String memberNum){
                return  professionDao.getByOidAndNum(oid,memberNum);
        }
}
